//
//  MusicCollectionViewCell.m
//  海角音乐
//
//  Created by dllo on 15/8/13.
//  Copyright (c) 2015年 杨元石. All rights reserved.
//

#import "MusicCollectionViewCell.h"
#import "CategoryModel.h"

@implementation MusicCollectionViewCell
- (void)dealloc
{
    [_imageView release];
    [_label release];
    [super dealloc];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        
        CGFloat width = self.contentView.frame.size.width;        
        
        self.imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,0, self.contentView.frame.size.width, self.contentView.frame.size.height)];
        _imageView.layer.masksToBounds = YES;
        _imageView.layer.cornerRadius = width/30;
        
        
        self.label = [[UILabel alloc]initWithFrame:CGRectMake(0, self.contentView.frame.size.height - 30*ADJUSTWIDTH, self.contentView.frame.size.width , 30*ADJUSTWIDTH)];
        _label.font = [UIFont boldSystemFontOfSize:18];
        _label.textColor =[UIColor whiteColor];
        
        [self.contentView addSubview:_imageView];
        [self.contentView addSubview:_label];
        [_imageView release];
        [_label release];
        
        self.imageButton = [[UIImageView alloc] initWithFrame:CGRectMake(110, 65, 30, 30)];
        self.imageButton.image = [UIImage imageNamed:@"iconfont-bofang-4.png"];
        [self.contentView addSubview:_imageButton];
        _imageButton.hidden = YES;
        [_imageButton release];
        
        
    }
    
    return self;
    
}

- (void)setModel:(CategoryModel *)model
{
    if (_model != model) {
        
        [_model release];
        _model = [model retain];
    }
    
    [_imageView sd_setImageWithURL:[NSURL URLWithString:model.pic_url_240_200] placeholderImage:[UIImage imageNamed:@"grid_default.png"]];
    
    [_label setCenter:CGPointMake(self.frame.size.width/2, 100/2)];
    
    _label.text = model.tag_name;
    
    _imageButton.hidden = NO;
    
}


@end
